
package com.manpower.common;

import org.springframework.http.HttpStatus;

public class BusinessException extends RuntimeException {
    private static final long serialVersionUID = 1L;
    private int errorCode;
    private String msg;

    public BusinessException(int code, String msg) {
        super(msg);
        this.errorCode = code;
        this.msg = msg;
    }

    public BusinessException(Throwable cause) {
        super(cause);
        this.errorCode = 1;
        this.msg = cause.getMessage();
    }

    public BusinessException(HttpStatus status) {
        this.errorCode = status.value();
        this.msg = status.getReasonPhrase();
    }

    public int getErrorCode() {
        return this.errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
